import { useState } from "react"
import useMount from '../../packages/useMount'
import { Button, message } from 'antd'

// eslint-disable-next-line react-refresh/only-export-components
const Child = () => {
  useMount(() => {
    message.info('mount')
  })
  return <div>child</div>
}

const useMountDemo =  () => {
  const [state, setState] = useState(false)

  return <>
    <p>点击挂载child 组件</p>
    <Button onClick={() => setState(!state)}>{state ? 'Unmount' : 'Mount'}</Button>
    {state && <Child />}
  </>
}

export default useMountDemo